package com.ftg.shopping.pro.service;


import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.ftg.shopping.config.LayuiPage;
import com.ftg.shopping.pro.entity.sp_productintroduction;
import com.ftg.shopping.pro.mapper.ProMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class ProService {

    @Autowired
    ProMapper proMapper;



    public LayuiPage<sp_productintroduction> list(){

        LayuiPage uid = new LayuiPage();
        uid.setData(proMapper.selectList(null));
        return uid;
    }

    public int savepro(sp_productintroduction p){
        return proMapper.insert(p);
    }

    public int deletepro(int id){
        return proMapper.deleteById(id);
    }
    public int updatepro(sp_productintroduction p){
        return proMapper.updateById(p);
    }




    public LayuiPage<sp_productintroduction> page1(int page, int limit, String id){
        IPage<sp_productintroduction> ip = new Page<>(page,limit);
        QueryWrapper qw = new QueryWrapper();
        qw.like("id",id);
        proMapper.selectPage(ip,id == null || id.equals("") ? null:qw);
        LayuiPage uid = new LayuiPage(ip);

        return uid;
    }



}
